package com.qf.bootdaily.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.bootdaily.entity.Daily;
import com.qf.bootdaily.mapper.DailyMapper;
import com.qf.bootdaily.service.DailyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(rollbackFor = Exception.class)
public class DailyServiceImpl implements DailyService {
    @Autowired
    DailyMapper dailyMapper;
    @Override
    public int insertSelective(Daily record) {
        return dailyMapper.insertSelective(record);
    }

    @Override
    public PageInfo<Daily> selectALl(Integer pageNum,Integer pageSize,Integer uid) {
        PageHelper.startPage(pageNum,pageSize);
        List<Daily> dailies = dailyMapper.selectALl(uid);
        return new PageInfo<>(dailies);
    }

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return dailyMapper.deleteByPrimaryKey(Long.valueOf(id));
    }
}
